package com.example.administrator.music;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import com.example.administrator.service.R;

public class Main2Activity extends Activity implements View.OnClickListener{
    private Button btnStartPlay;
    private Button btnStopPlay;
    private Intent intentPlay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        initView();
    }

    private void initView(){
        btnStartPlay = (Button)findViewById(R.id.btn_start_play);
        btnStopPlay = (Button)findViewById(R.id.btn_stop_play);

        btnStartPlay.setOnClickListener(this);
        btnStopPlay.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.btn_start_play:
                Toast.makeText(Main2Activity.this,"绑定了MusicPlaySerice",Toast.LENGTH_LONG).show();
                intentPlay = new Intent(Main2Activity.this,MusicService.class);
                startService(intentPlay);
                break;
            case R.id.btn_stop_play:
                stopService(intentPlay);
                Toast.makeText(Main2Activity.this,"解绑了MusicPlaySerice",Toast.LENGTH_LONG).show();
                break;
        }
    }
}
